package com.qckj.amz.controller;

import com.qckj.amz.domain.ProductTempExport;
import com.qckj.amz.service.IProductTempExportService;
import com.qckj.common.annotation.Log;
import com.qckj.common.core.controller.BaseController;
import com.qckj.common.core.domain.AjaxResult;
import com.qckj.common.core.page.TableDataInfo;
import com.qckj.common.enums.BusinessType;
import com.qckj.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 产品导出记录Controller
 *
 * @author luchuan
 * @since 1.0 2022-07-16
 */
@RestController
@RequestMapping("/amz/productTempExport")
public class ProductTempExportController extends BaseController {
    @Autowired
    private IProductTempExportService productTempExportService;

    /**
     * 查询产品导出记录列表
     */
    @PreAuthorize("@ss.hasPermi('amz:productTempExport:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductTempExport productTempExport) {
        Page<ProductTempExport> page = productTempExportService.findProductTempExportPage(productTempExport);
        return getDataTable(page);
    }

    /**
     * 导出产品导出记录列表
     */
    @PreAuthorize("@ss.hasPermi('amz:productTempExport:export')")
    @Log(title = "产品导出记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProductTempExport productTempExport) {
        List<ProductTempExport> list = productTempExportService.findProductTempExportList(productTempExport);
        ExcelUtil<ProductTempExport> util = new ExcelUtil<>(ProductTempExport.class);
        return util.exportExcel(list, "productTempExport");
    }

    /**
     * 获取产品导出记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('amz:productTempExport:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(productTempExportService.findById(id));
    }

    /**
     * 新增产品导出记录
     */
    @PreAuthorize("@ss.hasPermi('amz:productTempExport:add')")
    @Log(title = "产品导出记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductTempExport productTempExport) {
        productTempExportService.save(productTempExport);
        return AjaxResult.success();
    }

    /**
     * 修改产品导出记录
     */
    @PreAuthorize("@ss.hasPermi('amz:productTempExport:edit')")
    @Log(title = "产品导出记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductTempExport productTempExport) {
        productTempExportService.save(productTempExport);
        return AjaxResult.success();
    }

    /**
     * 删除产品导出记录
     */
    @PreAuthorize("@ss.hasPermi('amz:productTempExport:remove')")
    @Log(title = "产品导出记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        productTempExportService.deleteByIds(Arrays.asList(ids));
        return AjaxResult.success();
    }
}
